Skip to content

Conversation

@not-matthias
Copy link
Member

@not-matthias not-matthias commented Jan 14, 2026

TODO: REmove the custom memtrack installation before merging

@not-matthias not-matthias changed the title chore: bump instrument-hooks to support memory profiling feat: add memory profiling support Jan 14, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 14, 2026

Merging this PR will degrade performance by 39.4%

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 92 untouched benchmarks
🆕 56 new benchmarks
⏩ 100 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 WallTime BM_RLE_Encode_SmallRuns[100000] N/A 1.6 ms N/A
🆕 WallTime BM_RLE_Encode_SmallRuns[1000] N/A 16 µs N/A
🆕 WallTime BM_RLE_Encode_SmallRuns[100] N/A 1.8 µs N/A
🆕 WallTime BM_RLE_Encode_LargeRuns[100] N/A 213 ns N/A
🆕 WallTime BM_RLE_Encode_LargeRuns[10000] N/A 20.5 µs N/A
🆕 WallTime BM_RLE_Encode_SmallRuns[10000] N/A 154.7 µs N/A
🆕 WallTime BM_RLE_Encode_LargeRuns[1000] N/A 2.2 µs N/A
🆕 WallTime BM_RLE_Decode[100] N/A 368.5 ns N/A
🆕 WallTime BM_RLE_Encode_LargeRuns[100000] N/A 202.9 µs N/A
WallTime BM_StringCopy 10.4 ns 17.2 ns -39.4%
🆕 WallTime BM_Vector_PushBack[10] N/A 281.1 ns N/A
🆕 WallTime BM_RLE_Decode[10000] N/A 22 µs N/A
🆕 WallTime BM_Vector_PushBack[100] N/A 741.1 ns N/A
🆕 WallTime BM_Vector_PushBack[1000] N/A 3.7 µs N/A
🆕 WallTime BM_Vector_Reserve[10] N/A 66.8 ns N/A
🆕 WallTime BM_String_Concatenation[1000] N/A 8.3 µs N/A
🆕 WallTime BM_RLE_Decode[100000] N/A 279.2 µs N/A
🆕 WallTime BM_RLE_Decode[1000] N/A 2.7 µs N/A
🆕 WallTime BM_Vector_PushBack[10000] N/A 34.1 µs N/A
🆕 WallTime BM_String_Concatenation[100] N/A 987.5 ns N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing cod-1945-support-memory-profiling-for-c (003a1bf) with main (56e942a)

Open in CodSpeed

Footnotes

  1. 100 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@not-matthias not-matthias force-pushed the cod-1945-support-memory-profiling-for-c branch from 7b0a7b4 to 1b97510 Compare January 15, 2026 11:11
When running the warmup, we already call `start/stop_benchmark` which creates two memory profiles per benchmark, which breaks our assumptions in the backend.
@not-matthias not-matthias force-pushed the cod-1945-support-memory-profiling-for-c branch from b158911 to 003a1bf Compare January 15, 2026 17:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds memory profiling support to the benchmarking framework by introducing a new "memory" mode alongside the existing "simulation" and "walltime" modes. The changes unify the preprocessor directives and add the necessary configuration and infrastructure for memory profiling.

Changes:

  • Renamed CODSPEED_SIMULATION preprocessor macro to CODSPEED_ANALYSIS to better represent both simulation and memory profiling modes
  • Added "memory" as a new valid mode in CMake and Bazel build configurations
  • Removed warmup execution logic from simulation mode to reduce flakiness
  • Added memory benchmark examples demonstrating various allocation patterns
  • Updated CI workflows to test the new memory profiling mode with memtrack CLI installation

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
google_benchmark/src/benchmark_runner.cc Updated preprocessor directive from CODSPEED_SIMULATION to CODSPEED_ANALYSIS
google_benchmark/src/benchmark_api_internal.h Updated preprocessor directives and removed warmup execution logic
google_benchmark/src/benchmark_api_internal.cc Removed warmup repetition code from simulation mode
google_benchmark/src/benchmark.cc Updated preprocessor directives and console output message
google_benchmark/include/benchmark/benchmark.h Updated preprocessor directives throughout the State class
examples/google_benchmark_cmake/memory_bench.hpp Added new memory profiling benchmark examples with RLE encoding/decoding and allocation patterns
examples/google_benchmark_cmake/main.cpp Added include for new memory benchmark header
examples/google_benchmark_bazel/memory_bench.hpp Added symlink to cmake memory benchmark file
core/instrument-hooks Updated submodule commit reference
core/CMakeLists.txt Added "memory" to allowed modes and updated preprocessor definitions
core/BUILD Added memory_mode configuration and updated preprocessor defines
.github/workflows/ci.yml Added memory mode to test matrix and memtrack CLI installation steps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to 99
#ifdef CODSPEED_ANALYSIS
State BenchmarkInstance::RunSimulation(
codspeed::CodSpeed* codspeed, internal::ThreadTimer* timer,
internal::ThreadManager* manager,
internal::PerfCountersMeasurement* perf_counters_measurement,
ProfilerManager* profiler_manager) const {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name 'RunSimulation' is now misleading since CODSPEED_ANALYSIS covers both simulation and memory modes. Consider renaming to 'RunAnalysis' or a more generic name that reflects its broader purpose.

Copilot uses AI. Check for mistakes.
// Determine the width of the name field using a minimum width of 10.
#ifdef CODSPEED_SIMULATION
#ifdef CODSPEED_ANALYSIS
Err << "Codspeed mode: simulation" << "\n";
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message still says 'simulation' but this code path is now used for both simulation and memory modes under CODSPEED_ANALYSIS. The message should differentiate between these modes or be more generic.

Suggested change
Err << "Codspeed mode: simulation" << "\n";
Err << "Codspeed mode: analysis" << "\n";

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if printing analysis is the best UX, since we said it should be only the internal build mode. I guess we could forward the real measurement mode and then print that, while also enabling CODSPEED_WALLTIME/CODSPEED_ANALYSIS. wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants